import 'dart:convert';

import 'package:bruno/bruno.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:photo_view/photo_view.dart';

import '../../AppConfig/Config.dart';
import 'package:image/image.dart' as img;
import 'package:image_picker/image_picker.dart';

import 'dart:io';
class SingleComplaint extends StatefulWidget {
  const SingleComplaint({super.key});

  @override
  State<SingleComplaint> createState() => _SingleComplaintState();
}

class _SingleComplaintState extends State<SingleComplaint> {
  String ComplaintTypeStr="";
  String GoodsstatusStr="";
  String DisputeStr="";
  String AcknowledgeStr="";
  String NegotiationStr="";
  List imagePaths = [];
  List base64List=[];
  String? checkImage;
  List imagePaths2 = [];
  List base64List2=[];
  String? checkImage2;
  List getFileList=[];
  List getFileList2=[];
  List loadImgList=[];
  List unLoadImgList=[];
  List returnImgList=[];
  int chkecType=-1;
  void _copyToClipboard(String copyNumber) {
    Clipboard.setData(ClipboardData(text: copyNumber));
    BrnToast.show('复制成功', context);

  }
  final ImagePicker picker = new ImagePicker();
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        backgroundColor: Colors.white,
        centerTitle: true,
        title: Text("运单投诉",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w300,fontSize: 16.sp),),
      ),
        body: Column(
          children: [
            Expanded(
              child: ListView(
                children: [
                  Container(
                    margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10)),
                    ),
                    padding: EdgeInsets.only(left: 13.w,top: 15.h,bottom: 16.h),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Row(
                          children: [
                            Image.asset("lib/Images/OrderList/运单投诉手机icon.png",width: 18.w,height: 18.h,),
                            SizedBox(width: 7.w,),
                            Text("手机号",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                            Text("111****5555",style: TextStyle(color: MyColors.themeColor),),
                          ],
                        ),

                        SizedBox(height: 8.h,),
                        Container(height: 1.h,color: MyColors.backgreyColor,),
                        SizedBox(height: 15.h,),
                        Row(
                          children: [
                            Text("物流路线",style: TextStyle(color: MyColors.textColor),),
                            SizedBox(width: 8.w,),
                            Text("苏州市吴中区-苏州市吴中区",style: TextStyle(color: Colors.black),),
                          ],
                        ),
                        SizedBox(height: 6.h,),
                        Row(
                          children: [
                            Text("对方姓名",style: TextStyle(color: MyColors.textColor),),
                            SizedBox(width: 8.w,),
                            Text("张**",style: TextStyle(color: Colors.black),),
                          ],
                        ),
                        SizedBox(height: 6.h,),
                        Row(
                          children: [
                            Text("运单编号",style: TextStyle(color: MyColors.textColor),),
                            SizedBox(width: 8.w,),
                            Text("111122223333444444",style: TextStyle(color: Colors.black),),
                          ],
                        ),
                        SizedBox(height: 6.h,),
                        Row(
                          children: [
                            Text("运单状态",style: TextStyle(color: MyColors.textColor),),
                            SizedBox(width: 8.w,),
                            Text("已完成",style: TextStyle(color: Colors.black),),
                          ],
                        ),
                        SizedBox(height: 6.h,),
                        Row(
                          children: [
                            Text("运单时间",style: TextStyle(color: MyColors.textColor),),
                            SizedBox(width: 8.w,),
                            Text("2023-05-23 11:55:25",style: TextStyle(color: Colors.black),),
                          ],
                        ),
                      ],
                    ),
                  ),

                  Container(
                    margin: EdgeInsets.only(top: 8.h,left: 10.w,right: 10.w),
                    padding: EdgeInsets.only(top: 13.h,bottom: 13.h,left: 10.w,right: 10.w),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.all(Radius.circular(10)),
                    ),
                    child: Column(
                      children: [
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 16.sp),),
                            Text("选择投诉类型",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        GestureDetector(
                          child:
                          Container(
                            width: screenSize.width-40.w,
                            height: 30.h,
                            padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 5.h,bottom: 5.h),
                            decoration: BoxDecoration(
                                color: MyColors.backgreyColor,
                                borderRadius: BorderRadius.all(Radius.circular(10))),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(ComplaintTypeStr,style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                                Icon(Icons.arrow_forward_ios,color: MyColors.authTipColor,size: 20,),
                              ],
                            ),
                          ),
                          onTap: (){
                            showModalBottomSheet(
                              context: context,
                              builder: (BuildContext context) {
                                return Container(
                                  decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.all(Radius.circular(10))),
                                  padding: EdgeInsets.only(top: 10.h,left: 10.w,right: 10.w),
                                  height: 300,
                                  width: screenSize.width,
                                  child: Column(
                                    crossAxisAlignment: CrossAxisAlignment.center,
                                    children: [
                                      Row(
                                        mainAxisAlignment: MainAxisAlignment.end,
                                        children: [
                                          IconButton(onPressed: (){ComplaintTypeStr=""; Navigator.pop(context);}, icon: Icon(Icons.close,color: MyColors.authTipColor,)),

                                        ],
                                      ),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          ComplaintTypeStr ="货物损失";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("货物损失",style: TextStyle(color:ComplaintTypeStr =="货物损失"?MyColors.themeColor: Colors.black,fontSize: 16.sp),)),
                                      Divider(height: 1.h,color: MyColors.backgreyColor),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          ComplaintTypeStr ="司机把货拖走";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("司机把货拖走",style: TextStyle(color: ComplaintTypeStr =="司机把货拖走"?MyColors.themeColor:Colors.black,fontSize: 16.sp),)),

                                    ],
                                  ),

                                );
                              },
                            );
                          },
                        ),
                        SizedBox(height: 10.h,),
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 16.sp),),
                            Text("货物状态",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        GestureDetector(
                          child:
                          Container(
                            width: screenSize.width-40.w,
                            height: 30.h,
                            padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 5.h,bottom: 5.h),
                            decoration: BoxDecoration(
                                color: MyColors.backgreyColor,
                                borderRadius: BorderRadius.all(Radius.circular(10))),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(GoodsstatusStr,style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                                Icon(Icons.arrow_forward_ios,color: MyColors.authTipColor,size: 20,),
                              ],
                            ),
                          ),
                          onTap: (){
                            showModalBottomSheet(
                              context: context,
                              builder: (BuildContext context) {
                                return Container(
                                  decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.all(Radius.circular(10))),
                                  padding: EdgeInsets.only(top: 10.h,left: 10.w,right: 10.w),
                                  height: 300,
                                  width: screenSize.width,
                                  child: Column(
                                    crossAxisAlignment: CrossAxisAlignment.center,
                                    children: [
                                      Row(
                                        mainAxisAlignment: MainAxisAlignment.end,
                                        children: [
                                          IconButton(onPressed: (){GoodsstatusStr=""; Navigator.pop(context);}, icon: Icon(Icons.close,color: MyColors.authTipColor,)),

                                        ],
                                      ),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          GoodsstatusStr ="已卸货";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("已卸货",style: TextStyle(color:GoodsstatusStr =="已卸货"?MyColors.themeColor: Colors.black,fontSize: 16.sp),)),
                                      Divider(height: 1.h,color: MyColors.backgreyColor),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          GoodsstatusStr ="未装货";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("未装货",style: TextStyle(color: GoodsstatusStr =="未装货"?MyColors.themeColor:Colors.black,fontSize: 16.sp),)),
                                      Divider(height: 1.h,color: MyColors.backgreyColor),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          GoodsstatusStr ="未卸货";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("未卸货",style: TextStyle(color: GoodsstatusStr =="未卸货"?MyColors.themeColor:Colors.black,fontSize: 16.sp),)),
                                    ],
                                  ),

                                );
                              },
                            );
                          },
                        ),
                        SizedBox(height: 10.h,),
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 16.sp),),
                            Text("纠纷原因",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        GestureDetector(
                          child:
                          Container(
                            width: screenSize.width-40.w,
                            height: 30.h,
                            padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 5.h,bottom: 5.h),
                            decoration: BoxDecoration(
                                color: MyColors.backgreyColor,
                                borderRadius: BorderRadius.all(Radius.circular(10))),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(DisputeStr,style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                                Icon(Icons.arrow_forward_ios,color: MyColors.authTipColor,size: 20,),
                              ],
                            ),
                          ),
                          onTap: (){
                            showModalBottomSheet(
                              context: context,
                              builder: (BuildContext context) {
                                return Container(
                                  decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.all(Radius.circular(10))),
                                  padding: EdgeInsets.only(top: 10.h,left: 10.w,right: 10.w),
                                  height: 300,
                                  width: screenSize.width,
                                  child: Column(
                                    crossAxisAlignment: CrossAxisAlignment.center,
                                    children: [
                                      Row(
                                        mainAxisAlignment: MainAxisAlignment.end,
                                        children: [
                                          IconButton(onPressed: (){DisputeStr=""; Navigator.pop(context);}, icon: Icon(Icons.close,color: MyColors.authTipColor,)),

                                        ],
                                      ),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          DisputeStr ="货损";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("货损",style: TextStyle(color:DisputeStr =="货损"?MyColors.themeColor: Colors.black,fontSize: 16.sp),)),
                                      Divider(height: 1.h,color: MyColors.backgreyColor),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          DisputeStr ="货少/货错";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("货少/货错",style: TextStyle(color: DisputeStr =="货少/货错"?MyColors.themeColor:Colors.black,fontSize: 16.sp),)),

                                    ],
                                  ),

                                );
                              },
                            );
                          },
                        ),
                        SizedBox(height: 10.h,),
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 16.sp),),
                            Text("货物价值",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        Container(
                          width: screenSize.width-40.w,
                          padding: EdgeInsets.only(right: 10.w),
                          height: 50,
                          decoration: BoxDecoration(
                              color: MyColors.backgreyColor,
                              borderRadius: BorderRadius.all(Radius.circular(10))),
                          child: Row(

                            children: [
                              Container(
                                width: screenSize.width-80.w,
                                height: 50,
                                child: TextField(
                                    autofocus: false,
                                    decoration: InputDecoration(
                                      contentPadding: EdgeInsets.only(left: 10.0),
                                      hintText: '必填，请输入金额',
                                      hintStyle: TextStyle(color: MyColors.hintColor),
                                      border: InputBorder.none,
                                      filled: true, // 填充背景
                                      fillColor: MyColors.backgreyColor, // 背景色
                                    ),
                                    onChanged: (text){

                                    }),
                              ),
                              Text("元",style: TextStyle(color: MyColors.authTipColor,fontSize: 14.sp),),
                            ],
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          ),

                        ),
                        SizedBox(height: 10.h,),
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 16.sp),),
                            Text("货损金额",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        Container(
                          width: screenSize.width-40.w,
                          padding: EdgeInsets.only(right: 10.w),
                          height: 50,
                          decoration: BoxDecoration(
                              color: MyColors.backgreyColor,
                              borderRadius: BorderRadius.all(Radius.circular(10))),
                          child: Row(

                            children: [
                              Container(
                                width: screenSize.width-80.w,
                                height: 50,
                                child: TextField(
                                    autofocus: false,
                                    decoration: InputDecoration(
                                      contentPadding: EdgeInsets.only(left: 10.0),
                                      hintText: '必填，请输入金额',
                                      hintStyle: TextStyle(color: MyColors.hintColor),
                                      border: InputBorder.none,
                                      filled: true, // 填充背景
                                      fillColor: MyColors.backgreyColor, // 背景色
                                    ),
                                    onChanged: (text){

                                    }),
                              ),
                              Text("元",style: TextStyle(color: MyColors.authTipColor,fontSize: 14.sp),),
                            ],
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          ),

                        ),
                        SizedBox(height: 10.h,),
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 16.sp),),
                            Text("司机是否承认货损",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        GestureDetector(
                          child:
                          Container(
                            width: screenSize.width-40.w,
                            height: 30.h,
                            padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 5.h,bottom: 5.h),
                            decoration: BoxDecoration(
                                color: MyColors.backgreyColor,
                                borderRadius: BorderRadius.all(Radius.circular(10))),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(AcknowledgeStr,style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                                Icon(Icons.arrow_forward_ios,color: MyColors.authTipColor,size: 20,),
                              ],
                            ),
                          ),
                          onTap: (){
                            showModalBottomSheet(
                              context: context,
                              builder: (BuildContext context) {
                                return Container(
                                  decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.all(Radius.circular(10))),
                                  padding: EdgeInsets.only(top: 10.h,left: 10.w,right: 10.w),
                                  height: 300,
                                  width: screenSize.width,
                                  child: Column(
                                    crossAxisAlignment: CrossAxisAlignment.center,
                                    children: [
                                      Row(
                                        mainAxisAlignment: MainAxisAlignment.end,
                                        children: [
                                          IconButton(onPressed: (){AcknowledgeStr=""; Navigator.pop(context);}, icon: Icon(Icons.close,color: MyColors.authTipColor,)),

                                        ],
                                      ),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          AcknowledgeStr ="是";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("是",style: TextStyle(color:AcknowledgeStr =="是"?MyColors.themeColor: Colors.black,fontSize: 16.sp),)),
                                      Divider(height: 1.h,color: MyColors.backgreyColor),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          AcknowledgeStr ="否";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("否",style: TextStyle(color: AcknowledgeStr =="否"?MyColors.themeColor:Colors.black,fontSize: 16.sp),)),
                                    ],
                                  ),
                                );
                              },
                            );
                          },
                        ),
                        SizedBox(height:10 ,),
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 16.sp),),
                            Text("与司机协商的情况",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        GestureDetector(
                          child:
                          Container(
                            width: screenSize.width-40.w,
                            height: 30.h,
                            padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 5.h,bottom: 5.h),
                            decoration: BoxDecoration(
                                color: MyColors.backgreyColor,
                                borderRadius: BorderRadius.all(Radius.circular(10))),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(NegotiationStr,style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                                Icon(Icons.arrow_forward_ios,color: MyColors.authTipColor,size: 20,),
                              ],
                            ),
                          ),
                          onTap: (){
                            showModalBottomSheet(
                              context: context,
                              builder: (BuildContext context) {
                                return Container(
                                  decoration: BoxDecoration(
                                      color: Colors.white,
                                      borderRadius: BorderRadius.all(Radius.circular(10))),
                                  padding: EdgeInsets.only(top: 10.h,left: 10.w,right: 10.w),
                                  height: 300,
                                  width: screenSize.width,
                                  child: Column(
                                    crossAxisAlignment: CrossAxisAlignment.center,
                                    children: [
                                      Row(
                                        mainAxisAlignment: MainAxisAlignment.end,
                                        children: [
                                          IconButton(onPressed: (){NegotiationStr=""; Navigator.pop(context);}, icon: Icon(Icons.close,color: MyColors.authTipColor,)),

                                        ],
                                      ),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          NegotiationStr ="司机愿意赔偿全部损失";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("司机愿意赔偿全部损失",style: TextStyle(color:NegotiationStr =="司机愿意赔偿全部损失"?MyColors.themeColor: Colors.black,fontSize: 16.sp),)),
                                      Divider(height: 1.h,color: MyColors.backgreyColor),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          NegotiationStr ="司机愿意赔偿部分损失";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("司机愿意赔偿部分损失",style: TextStyle(color: NegotiationStr =="司机愿意赔偿部分损失"?MyColors.themeColor:Colors.black,fontSize: 16.sp),)),
                                      Divider(height: 1.h,color: MyColors.backgreyColor),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          NegotiationStr ="司机不愿赔偿";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("司机不愿赔偿",style: TextStyle(color: NegotiationStr =="司机不愿赔偿"?MyColors.themeColor:Colors.black,fontSize: 16.sp),)),
                                      Divider(height: 1.h,color: MyColors.backgreyColor),
                                      TextButton(onPressed: (){
                                        setState(() {
                                          NegotiationStr ="联系不上司机";
                                        });
                                        Navigator.pop(context);
                                      }, child: Text("联系不上司机",style: TextStyle(color: NegotiationStr =="联系不上司机"?MyColors.themeColor:Colors.black,fontSize: 16.sp),)),

                                    ],
                                  ),
                                );
                              },
                            );
                          },
                        ),
                        SizedBox(height:10 ,),
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 16.sp),),
                            Text("上传货损凭证",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        Row(
                          children: [
                            Text("最多可以上传10个凭证",style: TextStyle(color: MyColors.hintColor),),
                          ],
                        ),

                        Row(
                          children: [
                            Container(
                              child: Padding(
                                padding: const EdgeInsets.all(8.0),
                                child: Wrap(
                                  spacing: 8.0,
                                  runSpacing: 8.0,
                                  children: [
                                    ...imagePaths.map((path) => buildImageWidget(path,1)).toList(),
                                    buildAddImageWidget(1),
                                  ],
                                ),
                              ),
                            ),
                          ],
                        ),


                         SizedBox(height:10 ,),
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 16.sp),),
                            Text("上传证明货物价值的凭证",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        Row(
                          children: [
                            Text("最多可以上传10个凭证",style: TextStyle(color: MyColors.hintColor),),
                          ],
                        ),

                        Row(
                        children: [
                          Container(
                            child: Padding(
                              padding: const EdgeInsets.all(8.0),
                              child: Wrap(
                                spacing: 8.0,
                                runSpacing: 8.0,
                                children: [
                                  ...imagePaths2.map((path) => buildImageWidget(path,2)).toList(),
                                  buildAddImageWidget(2),
                                ],
                              ),
                            ),
                          ),
                        ],
                      ),


                        SizedBox(height:10 ,),
                        Row(
                          children: [
                            Text("*",style: TextStyle(color: MyColors.themeColor,fontSize: 16.sp),),
                            Text("投诉内容",style: TextStyle(color: Colors.black,fontSize: 16.sp),),
                          ],
                        ),
                        SizedBox(height:10 ,),
                        Container(
                          margin: EdgeInsets.only(top: 10.h),
                          child: BrnInputText(
                            autoFocus: false,
                            maxHeight: 200,
                            minHeight: 30,
                            minLines: 1,
                            maxLength: 140,
                            bgColor: MyColors.backgreyColor,
                            textInputAction: TextInputAction.newline,
                            maxHintLines: 20,
                            hint: '必填，请输入您要投诉的内容',
                            padding: EdgeInsets.fromLTRB(20, 10, 20, 14),
                            onTextChange: (text) {
                              print(text);

                              setState(() {});
                            },
                            onSubmit: (text) {
                              print(text);
                            },
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Container(
              height: 85.h,
              color: Colors.white,
              padding: EdgeInsets.only(top: 10.h,bottom: 40.h),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  BrnSmallOutlineButton(
                    width: screenSize.width/2-20.w,
                    radius: 30,
                    title: '发起投诉',
                    textColor: MyColors.themeColor,
                    lineColor: MyColors.themeColor,
                    fontWeight: FontWeight.w600,
                    onTap: () {
                      BrnToast.show('次按钮', context);
                    },
                  ),
                  SizedBox(width: 10.w,),
                  BrnSmallMainButton(
                    width: screenSize.width/2-20.w,
                    radius: 30,
                    title: '联系货主',
                    textColor: Colors.white,
                    bgColor: MyColors.themeColor,
                    fontWeight: FontWeight.w600,
                    onTap: () {
                      BrnToast.show('录需求信息', context);
                    },
                  )
                ],
              ),
            )
          ],
        )

    );
  }
  Widget buildImageWidget(String imagePath,int type) {
    return Container(
      width: 85.w,
      height: 85.h,
      child: Stack(
        children: [
          GestureDetector(
            onTap: () {
              // 处理点击查看图片的逻辑
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) => ImageViewer(imagePath),
                ),
              );
            },
            child:
            imagePath.contains('https')==false?
            Container(
              width: 75.w,
              height: 75.h,
              decoration: BoxDecoration(
                image: DecorationImage(

                  image: FileImage(File(imagePath)),
                  fit: BoxFit.cover,
                ),
                borderRadius: BorderRadius.circular(8.0),
              ),
            ):Container(
              width: 75.w,
              height: 75.h,
              decoration: BoxDecoration(
                image: DecorationImage(

                  image: NetworkImage(imagePath) ,
                  fit: BoxFit.cover,
                ),
                borderRadius: BorderRadius.circular(8.0),
              ),

            ),
          ),

          Positioned(
            top: 0,
            right: 0,
            child: GestureDetector(
              child: Icon(Icons.highlight_off,size: 30,color: MyColors.authTipColor,),
              onTap: () {
                setState(() {
                  print(imagePath);
                  if(type==1) {
                    imagePaths.remove(imagePath);
                    if(getFileList.toSet().contains(imagePath.replaceFirst(MyServiceUrl.imgHeader, '')))
                      getFileList.remove(imagePath.replaceFirst(MyServiceUrl.imgHeader, ''));
                  }
                  if(type==2) {
                    imagePaths2.remove(imagePath);
                    if(getFileList2.toSet().contains(imagePath.replaceFirst(MyServiceUrl.imgHeader, '')))
                      getFileList2.remove(imagePath.replaceFirst(MyServiceUrl.imgHeader, ''));
                  }

                });
              },
            ),
          ),
        ],
        alignment: Alignment.center,
      ),
    );
  }

  Widget buildAddImageWidget(int checkType) {
    return GestureDetector(
        onTap: () async {
          setState(() {
            chkecType=checkType;
          });
          showModalBottomSheet(context: context, builder: (BuildContext context) {
            return Container(
              color: Colors.white,
              child:
              Stack(

                children: [

                  Column(
                    mainAxisSize: MainAxisSize.min,
                    mainAxisAlignment:MainAxisAlignment.center,

                    children:[

                      SizedBox(height: 8.h,),
                      Row(
                        mainAxisAlignment:MainAxisAlignment.spaceBetween,
                        children: [
                          SizedBox(width: 30.w,),
                          Text("上传照片",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600,fontSize: 18.sp),),
                          IconButton(onPressed: (){
                            Navigator.of(context).pop();
                          }, icon:Icon(Icons.close,color: MyColors.authTipColor,)),
                        ],
                      ),


                      SizedBox(height: 8.h,),
                      Row(
                        children: [
                          SizedBox(width: 38.w,),
                          GestureDetector(
                            child:   Column(
                              children: [
                                Image.asset("lib/Images/Authentication/相册icon.png",width:35.w ,height: 35.h,),
                                Text("相册",style: TextStyle(color: Colors.black),),

                              ],

                            ),
                            onTap: ()async{
                              Navigator.of(context).pop();
                              final pickedFile = await picker.pickImage(source: ImageSource.gallery);

                              if (pickedFile != null) {

                                setState(() {
                                  checkImage = pickedFile.path;
                                  printImageMemorySize(File(checkImage!));
                                  print(checkImage);
                                  compressImage(File(checkImage!));
                                });
                              }
                            },
                          ),

                          SizedBox(width: 38.w,),
                          GestureDetector(
                            child: Column(
                              children: [
                                Image.asset("lib/Images/Authentication/拍照icon.png",width:35.w ,height: 35.h,),
                                Text("拍照",style: TextStyle(color: Colors.black),),

                              ],

                            ),
                            onTap: ()async{
                              Navigator.of(context).pop();
                              final pickedFile = await picker.pickImage(source: ImageSource.camera);

                              if (pickedFile != null) {
                                setState(() {
                                  checkImage = pickedFile.path;
                                  printImageMemorySize(File(checkImage!));
                                  print(checkImage);
                                  compressImage(File(checkImage!));

                                });
                              }
                            },
                          ),

                        ],
                      ),
                      SizedBox(height: 40.h,),
                    ],

                  ),

                ],

              ),
            );


          });


        },
        child: Image.asset("lib/Images/OrderList/图片管理上传照片.png",width: 85.w,height: 85.h,)
    );
  }

  void printImageMemorySize(File imageFile) {
    List<int> imageBytes = imageFile.readAsBytesSync();
    print('Original Image Memory Size: ${imageBytes.length} bytes');
  }

  Future<void> compressImage(File imageFile) async {
    List<int> imageBytes = await imageFile.readAsBytes();
    img.Image image = img.decodeImage(Uint8List.fromList(imageBytes))!;

    // Adjust the quality and size as needed
    img.Image compressedImage = img.copyResize(image, width: 1024);

    List<int> compressedBytes = img.encodeJpg(compressedImage, quality: 80);

    // Create a new File for the compressed image
    File compressedFile = File('${imageFile.path}_compressed.jpg');
    await compressedFile.writeAsBytes(compressedBytes);

    print('Compressed Image Size: ${compressedBytes.length} bytes');

    convertToBase64(compressedFile);
  }

  Future<void> convertToBase64(File imageFile) async {
    List<int> imageBytes = await imageFile.readAsBytes();
    String base64String = base64Encode(imageBytes);

    setState(() {

      if(chkecType==1){
        imagePaths.add(checkImage.toString());
        base64List.add(base64String);

      }

      if(chkecType==2){
        imagePaths2.add(checkImage.toString());
        base64List2.add(base64String);
      }


    });
  }


}
class ImageViewer extends StatelessWidget {
  final String imagePath;

  ImageViewer(this.imagePath);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GestureDetector(
        onTap: () {
          // 当点击大图时，返回上一个页面
          Navigator.pop(context);
        },
        child: PhotoView(
          imageProvider: FileImage(File(imagePath)),
          minScale: PhotoViewComputedScale.contained * 0.8,
          maxScale: PhotoViewComputedScale.covered * 2,
        ),
      ),
    );
  }

}


